package com.artconcurrency.chapter4;

/**
 * @ClassName com.artconcurrency.chapter4
 * Description: <类功能描述>. <br>
 * <p>
Exception in thread "Thread-0" java.lang.IllegalMonitorStateException
    at java.lang.Object.wait(Native Method)
    at java.lang.Object.wait(Object.java:502)
    at com.artconcurrency.chapter4.Synchronized$1.run(Synchronized.java:20)
    at java.lang.Thread.run(Thread.java:748)
 * </p>
 * @Author tree
 * @Date 2019-05-04 14:07
 * @Version 1.0
 */
public class Synchronized {
    public static void main(String[] args) {
        Object object = new Object();
        new Thread(new Runnable() {
            @Override
            public void run() {
                //wait／notify／notifyall必须使用synchronized来monitor，不然会抛出IllegalMonitorStateException
//                synchronized (object) {
                    try {
                        object.wait();
                    } catch (InterruptedException e) {
                        e.printStackTrace();
                    }
//                }
            }
        }).start();

    }
}
